/*
 *
 *
 *  Copyright (C) Microsoft Corporation.  All rights reserved
 *
 *
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CRMScenarios
{
    public partial class Scheduling_Information : Form
    {
        BaseUserControl parent = null;
        public Scheduling_Information(BaseUserControl Parent)
        {
            InitializeComponent();
            parent = Parent;
            dateStart.Value = DateTime.Today.AddDays(1);
            timeStart.Value = DateTime.Now;
            dateEnd.Value = DateTime.Today.AddDays(1);
            timeEnd.Value = DateTime.Now.AddMinutes(30);
        }


        private void dateStart_ValueChanged(object sender, EventArgs e)
        {
            dateEnd.MinDate = dateStart.Value.Date;
        }

        private void timeStart_ValueChanged(object sender, EventArgs e)
        {
        }

        private void dateEnd_ValueChanged(object sender, EventArgs e)
        {
        }

        private void timeEnd_ValueChanged(object sender, EventArgs e)
        {
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            DateTime Start = DateTime.Parse(dateStart.Value.ToShortDateString() + " " + timeStart.Value.ToShortTimeString(), System.Globalization.CultureInfo.CurrentUICulture);
            DateTime End = DateTime.Parse(dateEnd.Value.ToShortDateString() + " " + timeEnd.Value.ToShortTimeString(), System.Globalization.CultureInfo.CurrentUICulture);

            if (Start.CompareTo(End) < 0)
            {
                ((AttachDoc)parent).AppointmentSchedulingInf(Start, End);
                this.Dispose();
                return;
            }
            else
            {
                Util.ShowError(global::CRMScenarios.Resources.FutureEndTimeForbidden);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
            return;
        }
    }
}